# Transport layer source files

# Select corresponding implementation files based on transport type
set(TRANSPORT_SOURCES)

if(SDFX_TRANSPORT_TYPE STREQUAL "unix")
    list(APPEND TRANSPORT_SOURCES transport_unix.c)
elseif(SDFX_TRANSPORT_TYPE STREQUAL "tcp")
    list(APPEND TRANSPORT_SOURCES transport_tcp.c)
elseif(SDFX_TRANSPORT_TYPE STREQUAL "shm")
    list(APPEND TRANSPORT_SOURCES transport_shm.c)
elseif(SDFX_TRANSPORT_TYPE STREQUAL "custom")
    list(APPEND TRANSPORT_SOURCES transport_custom.c)
else()
    # Default to Unix socket
    list(APPEND TRANSPORT_SOURCES transport_unix.c)
endif()

add_library(sdfx_transport STATIC
    ${TRANSPORT_SOURCES}
)

# Set position-independent code flag
set_property(TARGET sdfx_transport PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(sdfx_transport PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/../include
)

target_include_directories(sdfx_transport PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/../../include
    ${CMAKE_CURRENT_SOURCE_DIR}/../../common/include
)

target_link_libraries(sdfx_transport
    ${COMMON_LIBS}
)

# Install library files
install(TARGETS sdfx_transport
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

# Install header files
install(FILES ../include/transport_interface.h
    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sdfx
)
